package com.zit.java.service.teacher;

import com.zit.java.dao.TeacherSalaryInputMapper;
import com.zit.java.pojo.TeacherSalaryInput;
import com.zit.java.pojo.TeacherSalaryInputExample;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class TeacherServiceImpl implements TeacherService {

    @Autowired
    private TeacherSalaryInputMapper mapper;

    @Override
    public List<TeacherSalaryInput> queryAllData() {
        return mapper.selectByExample(null);
    }

    @Override
    public int saveObj(TeacherSalaryInput ts) {
        int i = mapper.insertSelective(ts);
        return i;
    }

    @Override
    public TeacherSalaryInput queryDataById(Integer id) {
        TeacherSalaryInput teacherSalaryInput = mapper.selectByPrimaryKey(id);
        return teacherSalaryInput;
    }

    @Override
    public int updTeacherMsg(TeacherSalaryInput teacherSalaryInput) {
        int i = mapper.updateByPrimaryKeySelective(teacherSalaryInput);
        return i;
    }

    @Override
    public List<TeacherSalaryInput> queryQueryDataByName(String username) {
        TeacherSalaryInputExample tsie = new TeacherSalaryInputExample();
        TeacherSalaryInputExample.Criteria criteria = tsie.createCriteria();
        criteria.andNameLike("%"+username+"%");
        List<TeacherSalaryInput> teacherSalaryInputs = mapper.selectByExample(tsie);
        return teacherSalaryInputs;
    }

}
